package cn.line5.seam.student;

import java.util.List;

import cn.line5.seam.annotations.In;
import cn.line5.seam.annotations.Name;
import cn.line5.seam.annotations.Out;
import cn.line5.seam.annotations.Parameter;
import cn.line5.seam.db.PageResult;

@Name("studentRemote")
/**
 * <h1>LSEAM框架示例组件调用类</h1>
 * <br/>
 * 
 * @author Liu,yandong
 */
public class StudentRemote {

	@In("studentService")
	// 注入业务层接口
	private StudentService studentService;

	@Parameter
	// 参数
	private String id;

	@Parameter
	// 参数
	private String currentPage;

	@Parameter
	// 参数
	private StudentVo vo;

	@Parameter
	// 参数
	private String[] deleteId;

	@Out
	// 输出
	private String returnMessage;

	@Out
	// 输出
	private List<StudentVo> list;

	@Out
	// 输出
	private StudentVo returnVo;

	@Out
	// 输出
	private PageResult<StudentVo> pageResult;

	// 列表
	public void listStudent() {
		list = this.studentService.getList();
	}

	// 分页列表
	public void listPageStudent() {
		pageResult = this.studentService.getPageList(currentPage);
	}

	// 获取单个
	public void getStudent() {
		returnVo = this.studentService.getStudent(id);
	}

	// 在线报名
	public void signUpStudent() {
		returnVo = this.studentService.getStudentVo(vo);
		if(returnVo == null || returnVo.getStudentId().equals("")){
			this.studentService.saveStudent(vo);
			returnMessage = "报名成功！请等待校方电话联系您！";
		}else{
			returnMessage = "报名失败！您已经报过名了！";
		}
	}

	// 预约测试报名
	public void checkOutStudent() {
		returnVo = this.studentService.getStudentVo(vo);
		if(returnVo == null || returnVo.getStudentId().equals("")){
			this.studentService.saveStudent(vo);
			returnMessage = "预约测试报名成功！请等待校方电话联系您！";
		}else{
			returnMessage = "预约测试报名失败！您已经报过名了！";
		}
	}

	// 学生用户注册
	public void registerStudent() {
		returnVo = this.studentService.getStudentVo(vo);
		if(returnVo == null || returnVo.getStudentId().equals("")){
			this.studentService.saveStudent(vo);
		}else{
			returnVo.setStudentLoginAccount(vo.getStudentLoginAccount());
			returnVo.setStudentLoginPassword(vo.getStudentLoginPassword());
			this.studentService.saveStudent(returnVo);
		}
		returnMessage = "学生用户注册成功！24小时内核准！请等待";
	}
	// 更新
	public void modifyStudent() {
		this.studentService.saveStudent(vo);
	}

	// 删除
	public void deleteStudent() {
		this.studentService.deleteStudent(deleteId);
	}
}
